<?php
/**
 * @file testFilenameTime.php
 * @package DsCache
 * @subpackage 
 * @version $id: 0.1, utf8, Sat Dec  5 10:53:17 CST 2009
 * @author LD King <kldscs[at]gmail.com>
 * @copyright Copyright (c) 2007 - 2009 MiFunny China Inc. (http://mifunny.info)
 * @desc 
 *   测试 md5 与 preg_replace 所花的时间;
 * 结果: md5 会偶尔出现很快的美好幻觉; 
 */

/**
 * 得到当前时间
 */
function getMicrotime() {
	list ($usec, $sec) = explode(" ", microtime());
	return ((float) $usec + (float) $sec);
}

$id = ".SELECT * FROM dasdsa_DSADSA / dsad .dsa\n\t";

    $sTime = getMicrotime();
$filename = 'DsCache_' . md5($id) . '.php';
    $eTime = getMicrotime();
    $uTime = $eTime - $sTime;
    echo "<b>md5</b>: {$uTime}s. file: <i>'{$filename}'</i><br />\t\n"; 

    $sTime = getMicrotime();
$filename = 'DsCache_' . preg_replace("/[[:punct:]]|[[:space:]]/", '',  $id) . '.php';
    $eTime = getMicrotime();
    $uTime = $eTime - $sTime;
    echo "<b>preg_replace</b>: {$uTime}s. file: <i>'{$filename}'</i><br />\t\n"; 

?>
